package com.wlyuan.index.domain.source.valueobj;

import com.wlyuan.core.domain.valueobj.BillId;
import com.wlyuan.core.domain.valueobj.TenantId;
import com.wlyuan.tools.utils.CallUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDateTime;

/**
 * @author yuanjie
 */
@Builder
@AllArgsConstructor
@Getter
public final class Bill {
    private BillId billId;
    private BillNo billNo;
    private String billName;
    private LocalDateTime billAt;
    private BillStatus status;
    private TenantId tenantId;

    public boolean isCanBill() {
        // FIXME: 状态为空表示其它不在范围内的状态可以对账
        return null == status || status.isCanBill();
    }

    public boolean isCanQuote() {
        return (null == this.billId || status.isCanQuote());
    }

    public int getPriority() {
        return CallUtils.call(BillStatus::getPriority, status);
    }
}